package com.sg.hms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sg.hms.Model.Employee;
import com.sg.hms.Service.EmployeeService;
import com.sg.hms.ServiceImpl.EmployeeServiceImpl;
/**
 * 
 * @author 陈良机
 *
 */
public class UpEmplController extends HttpServlet{
	EmployeeService emservice=new EmployeeServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
    	resp.setCharacterEncoding("utf8");
    	int flag=0;
    	PrintWriter pw=resp.getWriter();
    	//获取修改员工的信息
        String elName=req.getParameter("elName");
        String elSex=req.getParameter("elSex");
        int elAge=Integer.parseInt(req.getParameter("elAge"));
        String tellphone=req.getParameter("tellphone");
        String enterTime=req.getParameter("enterTime");
        Double salary=Double.parseDouble(req.getParameter("salary"));
        String state=req.getParameter("state");
        int dId=Integer.parseInt(req.getParameter("dId"));
        int elId=Integer.parseInt(req.getParameter("elId"));
        Employee em=new Employee(elId, elName, elSex, elAge, tellphone, enterTime, dId, salary, state);
        if(elName==""||elSex==""||elAge==0||tellphone==""||enterTime==""||salary==0||state==""||dId==0){
        	pw.write(String.valueOf(flag));
        }else{
        	 flag=emservice.upEmpl(em);
        	 pw.write(String.valueOf(flag));
        }
        	pw.flush();
        	pw.close();
	}
}
